package com.qf.aop;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * @author sunyamei
 * @version V1.0
 * @Project spring_demo
 * @Package com.qf.aop
 * @Description:
 * @Date 2022/7/11 21:51
 */
public class MyAroundAdvice implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {

        Object result = null;
        try {
            System.out.println("前置通知");
            result = methodInvocation.proceed();//触发核心方法执行;
            System.out.println("后置通知");
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            System.out.println("异常通知");
        }finally {
            System.out.println("最终通知");
        }
        return result;

    }
}
